<?php

namespace app\zz_article\controller;

use app\common\controller\Api;
use app\zz_article\model\ArticleM;
use think\Validate;

class ArticleDetail extends Api
{
    protected $noNeedLogin = '*';

    public function index()
    {
        $validate = new Validate();
        if (!$validate->check(input(), [
            'id' => 'require|integer',
        ])) {
            $this->error($validate->getError());
        }
        $id      = input('id');
        $query   = ArticleM::where([
            'status' => 'normal',
            'id'     => $id,
        ]);
        $article = $query->find();
        if (empty($article)) {
            $this->error('error id');
        }
        $this->success('', $article);
    }
}
